<template>
  <div>
    <vxe-table
      border
      show-header-overflow
      show-overflow
      highlight-hover-row
      :align="allAlign"
      :data="tableData"
    >
      <vxe-table-column type="seq" title="序号" width="60"></vxe-table-column>
      <vxe-table-column
        field="productInfo.productName"
        title="物料名称"
        min-width="100"
      ></vxe-table-column>
      <vxe-table-column title="物料图片" min-width="100">
        <template #default="{ row }">
          <a-avatar :src="row.productInfo.productImage" />
        </template>
      </vxe-table-column>
      <vxe-table-column
        field="productNum"
        title="进货数量（个）"
        min-width="100"
      ></vxe-table-column>
      <vxe-table-column
        field="payNum"
        title="支付金额（元）"
        min-width="100"
      ></vxe-table-column>
      <vxe-table-column
        field="storehouseInfo.srName"
        title="进货仓库"
        min-width="100"
      ></vxe-table-column>
      <vxe-table-column
        field="storehouseInfo.srSite"
        title="仓库地址"
        min-width="200"
      ></vxe-table-column>
      <vxe-table-column title="进货状态" min-width="100">
        <template #default="{ row }">
          <a-button type="danger" ghost size="small">
            {{ row.productStatus.role }}
          </a-button>
        </template>
      </vxe-table-column>
      <vxe-table-column title="操作人员" min-width="100">
        <template #default="{ row }">
          <a-button type="primary" size="small">
            {{ row.adminInfo.userNickname }}
          </a-button>
        </template>
      </vxe-table-column>
      <vxe-table-column field="updateTime" title="进货时间" min-width="200">
        <template #default="{ row }">
          <a-button type="link">
            {{ tenBitTimestamp(row.updateTime) }}
          </a-button>
        </template>
      </vxe-table-column>
    </vxe-table>
    <a-pagination
      show-quick-jumper
      :default-current="1"
      :total="totalNum"
      @change="onChange"
    />
  </div>
</template>

<script>
import { inputRecord } from '@/api/materials'
import { thirteenBitTimestamp } from '@/utils/index'
export default {
  data() {
    return {
      allAlign: 'center',
      //   apiData
      ApiData: {
        pageNum: 1,
        pageSize: 10,
        storehouseName: '',
        type: '0',
        username: '',
      },
      tableData: [],
      totalNum: 0,
    }
  },
  created() {
    this.inputRecordList()
  },
  methods: {
    onChange(pageNumber) {
      this.ApiData.pageNum = pageNumber
      this.inputRecordList()
    },
    /**
     * 入库记录查询
     */
    inputRecordList() {
      inputRecord(this.ApiData).then((res) => {
        this.tableData = res.queryResult.list
        this.totalNum = res.queryResult.total
      })
    },
    /**
     * 时间撮传话
     */
    tenBitTimestamp(time) {
      return thirteenBitTimestamp(time)
    },
  },
}
</script>

<style lang="less" scoped>
</style>